﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace School_Management
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void CreateUserButton_Click(object sender, EventArgs e)
        {
            string strcon = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
            SqlConnection con = new SqlConnection();
            con.ConnectionString = strcon;
            con.Open();

            string cmdtext = "insert  into Users(UserName,Email,Password) values(@username,@email,@password)";
            SqlCommand cmd = new SqlCommand(cmdtext,con);
            cmd.Parameters.AddWithValue("@username", UserName.Text);
            cmd.Parameters.AddWithValue("@email", Email.Text);
            cmd.Parameters.AddWithValue("@password", Password.Text);

            int retvalue = cmd.ExecuteNonQuery();
            con.Close();
            if(retvalue > 0)
                Response.Redirect("Login.aspx");
            
        }
    }
}